<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>倒计时案例</title>
</head>

<body>
  <button disabled>按钮</button>
  <p>5</p>
  <script>
    const btn = document.querySelector('button')
    const p = document.querySelector('p')
    let i = 5
    let timer = setInterval(function () {
      p.innerHTML = i
      i--

      if (i === -1) {
        clearInterval(timer)
        btn.disabled = false
        btn.innerHTML = '同意'
      }
    }, 1000)

  </script>
</body>

</html>